package func_demo

import (
	"fmt"
	"reflect"
	"strings"
)

func MaxData(i1, i2 int) int {
	if i1 > i2 {
		return i1
	} else {
		return i2
	}
}

// SumData 求和
func SumData(i1, i2 int) (result int) {
	result = i1 + i2
	return
}

func SortData(i1, i2 int) (max, min int) {
	if i1 > i2 {
		max = i1
		min = i1
	} else {
		max = i2
		min = i1
	}
	return
}

func AnyParamData(s ...string) string {
	//s的类型是切片
	fmt.Println(s, reflect.TypeOf(s))
	fmt.Println("参数长度:", len(s))
	return strings.Join(s, "-")
}

func FactorialData(n int) (result int) {
	if n <= 0 {
		panic("阶乘参数必须大于0")
	}
	if n > 1 {
		result = n * FactorialData(n-1)
	} else {
		result = n
	}
	return result
}

func FactorialDemo(n int) (result int) {
	if n > 0 {
		result = n * FactorialDemo(n-1)
	} else {
		result = 1
	}
	return
}
